from rest_framework import serializers
from knight_api.models import *
# 菜单
class MenuSerializer(serializers.ModelSerializer):

    class Meta:
        model = MenuModel
        fields = '__all__'
        # depth = 1
    def get_fields(self):
        fields = super(MenuSerializer, self).get_fields()
        fields['children'] = MenuSerializer(many=True)

        return fields
# 用户
class AdminSerializer(serializers.ModelSerializer):
    role_id = serializers.IntegerField()
    role = serializers.StringRelatedField(read_only=True)
    class Meta:
        model = AdminModel
        fields = '__all__'

# 角色
class RoleSerializer(serializers.ModelSerializer):
    class Meta:
        model = RoleModel
        fields = '__all__'

# 用户日志
class LoginMesSerializer(serializers.ModelSerializer):
    admin_id = serializers.IntegerField()
    admin = serializers.StringRelatedField(read_only=True)
    class Meta:
        model = LoginMesModel
        fields = '__all__'


# 会员管理
class MemberSerializer(serializers.ModelSerializer):
    platform_id = serializers.IntegerField()
    platform = serializers.StringRelatedField(read_only=True)

    class Meta:
        model = MemberModels
        fields = '__all__'

class PlatfromSerializer(serializers.ModelSerializer):
    class Meta:
        model = PlatfromModels
        fields = '__all__'




# #######简历管理
# 城市自关联
class CitycategorySerializer(serializers.ModelSerializer):

    class Meta:
        model = Citycategory
        fields = ['label','value']
        # depth = 1
    def get_fields(self):
        fields = super(CitycategorySerializer, self).get_fields()
        fields['children'] = CitycategorySerializer(many=True)

        return fields

class CitycategorySerializer2(serializers.ModelSerializer):

    class Meta:
        model = Citycategory
        fields = "__all__"
        # depth = 1
    def get_fields(self):
        fields = super(CitycategorySerializer2, self).get_fields()
        fields['children'] = CitycategorySerializer2(many=True)

        return fields

# 专业种类
class JobmajorsSerializer(serializers.ModelSerializer):

    class Meta:
        model = Jobmajors
        fields = "__all__"
        # depth = 1
    def get_fields(self):
        fields = super(JobmajorsSerializer, self).get_fields()
        fields['children'] = JobmajorsSerializer(many=True)

        return fields

# 学历
class EductionSerializer(serializers.ModelSerializer):
    class Meta:
        model = Eduction
        fields = '__all__'


# Jobcategory工作种类自关联
class JobcategorySerializer(serializers.ModelSerializer):

    class Meta:
        model = Jobcategory
        fields = ['label','value']
        # depth = 1
    def get_fields(self):
        fields = super(JobcategorySerializer, self).get_fields()
        fields['children'] = JobcategorySerializer(many=True)

        return fields

class JobcategorySerializer2(serializers.ModelSerializer):

    class Meta:
        model = Jobcategory
        fields = '__all__'
        # depth = 1
    def get_fields(self):
        fields = super(JobcategorySerializer2, self).get_fields()
        fields['children'] = JobcategorySerializer2(many=True)

        return fields


# 审核状态
class ResumeAuditSerializer(serializers.ModelSerializer):
    class Meta:
        model = ResumeAudit
        fields = '__all__'

# 职位信息
# 招聘信息 状态
class JobDisplaySerializer(serializers.ModelSerializer):
    class Meta:
        model = JobDisplay
        fields = '__all__'

# 公司福利
class JobTagSerializer(serializers.ModelSerializer):
    class Meta:
        model = JobTag
        fields = '__all__'

# 职位性质

class JobNatureSerializer(serializers.ModelSerializer):
    class Meta:
        model = JobNature
        fields = '__all__'

# 工作经验

class ExperienceSerializer(serializers.ModelSerializer):
    class Meta:
        model = Experience
        fields = '__all__'

# 公司信息表
class CompanySerializer(serializers.ModelSerializer):
    class Meta:
        model = Company
        fields = '__all__'

#联系方式
class ContactSerializer(serializers.ModelSerializer):
    class Meta:
        model = Contact
        fields = '__all__'


# 职位信息
class PositionInfoSerializer(serializers.ModelSerializer):
    audit_id = serializers.IntegerField()
    audit = serializers.StringRelatedField(read_only=True)

    company_id = serializers.IntegerField()
    company = serializers.StringRelatedField(read_only=True)

    contact_id = serializers.IntegerField()
    contact = serializers.StringRelatedField(read_only=True)

    education_id = serializers.IntegerField()
    education = serializers.StringRelatedField(read_only=True)

    experience_id = serializers.IntegerField()
    experience = serializers.StringRelatedField(read_only=True)

    platform_id = serializers.IntegerField()
    platform = serializers.StringRelatedField(read_only=True)
    job_display_id = serializers.IntegerField()
    job_display = serializers.StringRelatedField(read_only=True)

    class Meta:
        model = PositionInfo
        fields = '__all__'


# #####广告位type
# class Regin_fromSerializers(serializers.ModelSerializer):
#     class Meta:
#         model = Regin_from
#         fields = '__all__'
#


class Regin_typeSerializers(serializers.ModelSerializer):
    class Meta:
        model = Regin_type
        fields = '__all__'

##广告位
class Regin_ggSerializers(serializers.ModelSerializer):
    region_id = serializers.IntegerField()
    region = serializers.StringRelatedField(read_only=True)
    type_id = serializers.IntegerField()
    type = serializers.StringRelatedField(read_only=True)
    class Meta:
        model = Regin_gg
        fields = '__all__'



# ###广告列表
class Gg_listSerializers(serializers.ModelSerializer):
    company_id = serializers.IntegerField()
    company = serializers.StringRelatedField(read_only=True)
    cname_id = serializers.IntegerField()
    cname = serializers.StringRelatedField(read_only=True)
    platform_id = serializers.IntegerField()
    platform = serializers.StringRelatedField(read_only=True)

    class Meta:
        model = ADlist
        fields = '__all__'




# class Questionssserializer(serializers.ModelSerializer):
#     class Meta:
#         # model = QuestionsModel
#         fields = '__all__'
#
#
# class ChoiceSerializer(serializers.ModelSerializer):
#     question_id =serializers.IntegerField()
#     # question = serializers.StringRelatedField(read_only=True)
#     question = Questionssserializer(read_only=True)
#     class Meta:
#         model = ChoiceModel
#         fields = '__all__'
#
#
# class Questionsserializer(serializers.ModelSerializer):
#     choicemodel_set = ChoiceSerializer(many=True, read_only=True)
#     class Meta:
#         # model = QuestionsModel
#         fields = '__all__'
